package com.lanju.service.impl;


import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.lanju.dao.SMSCaptchaDao;
import com.lanju.entity.SMSCaptcha;
import com.lanju.model.ResultModel;
import com.lanju.service.SMSService;


@Service
public class SMSServiceImpl implements SMSService{

    private static final Logger LOGGER = LoggerFactory.getLogger(SMSServiceImpl.class);
    
    @Autowired
    SMSCaptchaDao sMSCaptchaDao;

   

    @Override
    @Transactional(value="financialmarketingTM", rollbackFor = Exception.class)
    public ResultModel addSMSCaptcha(SMSCaptcha sms) {
        try {
        	if(sms!=null){
        		sMSCaptchaDao.persist(sms);
                return ResultModel.success();
        	}
        } catch (Exception e) {
            LOGGER.error("addSMSCaptcha fail",e);
        }
        return ResultModel.fail();
    }



	@Override
	public boolean isPhoneCaptcha(Map<String, Object> param) {
		String phone = (String)param.get("phone");
		String captcha = (String)param.get("captcha");
		return sMSCaptchaDao.isPhoneCaptcha(phone, captcha);
	}

 

}
